package com.wb.system.service.impl;

import com.wb.common.vo.MaterialsModelVO;
import com.wb.system.domain.MaterialsEntity;
import com.wb.system.mapper.MaterialsMapper;
import com.wb.system.service.MaterialsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MaterialsServiceImpl implements MaterialsService {
    @Autowired
    private MaterialsMapper materialsMapper;

    @Override
    public List<MaterialsEntity> selectMaterialsList(MaterialsModelVO materialsModelVO) {
        return materialsMapper.selectMaterialsList(materialsModelVO);
    }

    @Override
    public MaterialsEntity selectById(Long id) {

        return materialsMapper.selectById(id);
    }

    @Override
    public void saveMaterials(MaterialsEntity materialsEntity) {
        materialsEntity.setDelFlag("0");
        materialsMapper.saveMaterials(materialsEntity);
    }

    @Override
    public void updateMaterialsById(MaterialsEntity materialsEntity) {
        materialsMapper.updateMaterialsById(materialsEntity);
    }

    @Override
    public void removeMaterialsByIds(List<Long> ids) {
        if (ids != null && ids.size() > 0) {
            for (Long id : ids) {
                materialsMapper.removeMaterialsById(id);
            }
        }
    }
}
